Because the Speech Manager is not available in all system software versions, your application should always check for speech capabilities before attempting to use them. Listing 0-7 defines a function that determines whether the Speech Manager is available.
Listing 7 Checking for speech generation capabilities
FUNCTION MyHasSpeech: Boolean;
VAR
myFeature: LongInt; {feature being tested}
myErr: OSErr;
BEGIN
myErr := Gestalt(gestaltSpeechAttr, myFeature);
IF myErr = noErr THEN {test Speech Manager-present bit}
MyHasSpeech := BTst(myFeature, gestaltSpeechMgrPresent)
ELSE
MyHasSpeech := FALSE; {no speech features available}
END;
The MyHasSpeech function defined in Listing 0-7 uses the Gestalt function to determine whether the Speech Manager is available. The MyHasSpeech function tests the gestaltSpeechMgrPresent bit and returns TRUE if and only if the Speech Manager is present. If the Gestalt function cannot obtain the desired information and returns a result code other than noErr , the MyHasSpeech function assumes that the Speech Manager is not available and therefore returns FALSE .
| Previous | Chapter contents | Chapter top | Section top | Next |